﻿using log4.Module;
using log4net;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Net;
using System.Net.Http;
using System.Web.Http;

namespace log4.Controllers
{
    public class ValuesController : ApiController
    {
       
        // GET api/values
        public IEnumerable<string> Get()
        {
            try
            {

            }
            catch (Exception ex)
            {

                throw;
            }
            return new string[] { "value1", "value2" };
        }

        // GET api/values/5
        public string Get(int id)
        {
            // 通过LogManager的静态方法GetLogger生成一个Ilog对象
            //LogHelper.Debug("测试debug");
            //LogHelper.Info("测试Info");
            try
            {
                int[] arr = new int[2];
                for (int i = 0; i < 3; i++)
                {
                    arr[i] = i;
                }
            }
            catch (Exception ex)
            {

                LogHelper.Error("Error",ex);
            }
          
            return "已经写入日志";
        }

        // POST api/values
        public void Post([FromBody] string value)
        {
        }

        // PUT api/values/5
        public void Put(int id, [FromBody] string value)
        {
        }

        // DELETE api/values/5
        public void Delete(int id)
        {
        }
    }
}
